import React from "react";
import {Icon} from "weaver-mobile";
import PropTypes from "prop-types";

/**
 * 列表操作
 * jiansong 2019/11/8
 */

/**
 * @param showOperate 是否展示操作
 * @param data 操作按钮数据
 * 格式：[{label:"操作名称",iconname:"操作图标",onClick:()=>{操作点击方法}]
 */
const WrListCardOperate = ({showOperate = false, data = []}) => (
    <div className="workrelate-listcard-operate">
        {showOperate && <div className="item-operation">
            {data.map((item, index) =>
                (
                    <span key={index} onClick={item.onClick}>
                        <Icon type={item.iconname} className="item-icon"/>
                        {item.label}
                   </span>
                )
            )}
        </div>}
    </div>
)

WrListCardOperate.propTypes = {
    showOperate: PropTypes.bool,
    data: PropTypes.array
}
export default WrListCardOperate;